using UnityEngine;
using System.Collections;

public static class MathHelper
{
	public static void setForward(this Transform vTransform, Vector3 vForward, Vector3 vUp)
	{
		vTransform.LookAt(vTransform.position + vForward, vUp);
	}
	
	public static Vector3 blendPositions(Vector3 v1, Vector3 v2, float fV2)
	{
		if (fV2 > 1.0f) fV2 = 1.0f;
		Vector3 res = v1 * (1.0f - fV2) + v2 * fV2;
		return res;
	}
	
	public static Vector3 blendDirections(Vector3 v1, Vector3 v2, float fV2)
	{
		if (fV2 > 1.0f) fV2 = 1.0f;
		Vector3 res = v1 * (1.0f - fV2) + v2 * fV2;
		return res.normalized;
	}
	
	public static float blend(float a, float b, float fB)
	{
		return  a * (1.0f - fB) + b * fB;
	}
	
	public static float getSignedAngle(Vector3 v1, Vector3 v2, Vector3 vN)
	{
		float theta = Mathf.Acos(Vector3.Dot(v1, v2));
		Vector3 v3 = Vector3.Cross(vN, v1);
		if (Vector3.Dot(v3, v2) < 0.0f)
		{
			return -theta;
		}
		return theta;
	}
	
	public static void rotateAround(this Vector3 v, Vector3 vAxis, float fDegrees)
	{
		Quaternion q = Quaternion.AngleAxis(fDegrees, vAxis);
		v = q * v;
	}
}